package com.yuwei.mine.adapter

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.yuwei.mine.R
import com.yuwei.mine.databinding.LayoutOrderStatusBinding
import com.yuwei.mine.entity.OrderStatusEntity

class OrderStatusAdapter(private val data:List<OrderStatusEntity>, var title:String) :RecyclerView.Adapter<OrderStatusAdapter.OrderStatusViewHolder>() {

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): OrderStatusViewHolder {
        val itemBinding=LayoutOrderStatusBinding.inflate(LayoutInflater.from(parent.context),parent,false)
        return OrderStatusViewHolder(itemBinding)
    }

    override fun getItemCount(): Int {
       return data.size
    }

    override fun onBindViewHolder(holder: OrderStatusViewHolder, position: Int) {
//        val itemData=data[position]
//        holder.itemView.findViewById<TextView>(R.id.tv_status).setText(itemData.title)
//        val check = holder.itemView.findViewById<ImageView>(R.id.iv_check)
//        holder.itemView.setOnClickListener {
//            title=itemData.title
//            for (i in data.indices){
//                data[i].isSelected=false
//            }
//            itemData.isSelected=true
//           check.visibility= if(itemData.isSelected) View.VISIBLE else View.GONE
//        }
    }

    class OrderStatusViewHolder(val itemBinding:LayoutOrderStatusBinding):RecyclerView.ViewHolder(itemBinding.root)

}